/**
 * @title CustomConfirmDialog.java
 * @package com.esun.cheetah.view.personal.bindphone
 * @description 
 * @author liugan
 * @date 2012-4-25
 * @copyright 深圳市易讯天空
 */
package com.esun.cheetah.view.custom;

import com.esun.cheetah.R;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * @title CustomConfirmDialog
 * @description
 * @author liugan
 */
public class CustomConfirmDialog extends Dialog {
	private Button mConfirmButton;
	private Button mCancelButton;
	private TextView mTextView;
	private CharSequence mMessage;
	private View.OnClickListener mConfirmListener;
	private View.OnClickListener mCancelListener;

	/**
	 * @param context
	 */
	public CustomConfirmDialog(Context context) {
		super(context, R.style.dialog);
		setContentView(R.layout.dialog_confirm_view);
		mConfirmButton = (Button) findViewById(R.id.btn_dialog_confirm);
		mCancelButton = (Button) findViewById(R.id.btn_dialog_cancel);
		mTextView = (TextView) findViewById(R.id.tv_dialog_message);

		mCancelButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}

	@Override
	protected void onStart() {
		mTextView.setText(mMessage);
		if (mConfirmListener != null) {
			mConfirmButton.setOnClickListener(mConfirmListener);
		}
		if (mCancelListener != null) {
			mCancelButton.setOnClickListener(mCancelListener);
		}
	}

	public void setMessage(CharSequence message) {
		this.mMessage = message;
	}

	public void setOnConfirmListener(View.OnClickListener l) {
		this.mConfirmListener = l;
	}

	public void setOnCancelListener(View.OnClickListener l) {
		this.mCancelListener = l;
	}

}
